import type { ResponseData, ResponsePaginationData } from '@/utils/request';
import type { RequestData } from '@ant-design/pro-table';
import { request } from 'umi';
import type { QueryParams } from './types';

//查询单个数据
export async function getRecordDetail(id: string) {
  return await request(`/parking/access/record/${id}`);
}

//通行记录列表
export async function getRecordTable(
  params: QueryParams,
): Promise<ResponsePaginationData<RequestData<any>>> {
  return await request('/parking/access/record', {
    params: {
      ...params,
      page: params.current,
      pageSize: params.pageSize,
      startPassTime: params?.passTime && params?.passTime[0],
      endPassTime: params?.passTime && params?.passTime[1],
      releaseType: params.releaseMode,
      channelId: params.channelName?.id,
      zoneId: params.zoneName?.id,
    },
  });
}

//强制停车
export async function deletePark(params: { id: string }): Promise<ResponseData<any>> {
  return await request(`/zone/zone/${params.id}`, {
    method: 'DELETE',
  });
}

//获取相机分页查询
export async function gateCameraItem(params: {
  name?: string;
  // tenantId: number;
  page?: number;
  pageSize?: number;
}): Promise<ResponseData<any>> {
  return await request('/traffic/channel/get_channel_options', {
    params: {
      ...params,
    },
  });
}
